<?php
	include('include/header.php');
?>
<title>Login</title>
    <div id="headline">
        <div class="wrapper">
            <h2>Login</h2>
        </div>
    </div>    
<div id="pagebody">
	<div class="wrapper">
<?php
    if (isset($_GET['errorMsg']))
		echo "<div class=\"notice\">{$_GET['errorMsg']}</div>";
?>
    <form name=loginform
        action="login.do"
        method="post"
        onsubmit="encode(this.password.value)">
    <table class="center" id="register"><tbody>
        <tr>
            <td>
                <strong>User ID:&nbsp;&nbsp;</strong>
            </td>
            <td>
                <input class="text"  name="user_id" tabIndex=1 value="<?php
                    if (isset($_COOKIE['user_id']))
                        echo htmlspecialchars($_COOKIE['user_id']);
                ?>" size=20 maxlength=150 />
            </td>
        </tr>
         <tr>
            <td>
                <strong>Password:</strong>
            </td>
            <td>
                <input class="text"  name="password" id="ps" type="password" tabIndex="2" value="<?php
                    if (isset($_COOKIE['password']))
                        echo htmlspecialchars($_COOKIE['password']);
                    ?>" size=20 maxLength=150 />
            </td>
        </tr>
       <tr>
            <td colspan="2">
                <input name="autoLogin" type="checkbox" class="radio" tabIndex="3" value="true" <?php if(!empty($_COOKIE['user_id'])) echo "checked"; ?> />
                Remember Me
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <input class="button-secondary" tabIndex="4" type="submit" value="Login" name="doLogin" />&nbsp;
		        <input class="button-secondary" tabIndex="5" type="reset" value="Reset" name="doCancel" />
            </td>
        </tr>
    </tbody></table>
    </form>
    <br/><br/><br/>
    </div>
</div>

        <script src="common/md5.js"></script>
        <script language="javascript">
            function check() {
                var ps = document.getElementById('ps');
                if (ps.value.length <= 0) {
                    alert("Your password cannot be NULL.");
                    return false;
                }
                if (ps.value.length < 32)
                    ps.value = MD5(ps.value);
                else if (ps.value.length > 32) {
                    alert("Your password is too long.");
                    return false;
                }
                return true;
            }
        </script>

<?php
	include('include/footer.php');
?>
